package TCPDemo;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo {
    public static void main(String[] args) throws IOException {
        // ServerSocket(int port)创建绑定到指定端口的服务器套接字。
        ServerSocket ss = new ServerSocket(12345);

        //Socket accept()侦听要连接到此套接字并接受它。
        Socket accept = ss.accept();

        InputStream is = accept.getInputStream();
        byte[] bys = new byte[1024];
        int len = is.read(bys);
        String data = new String(bys, 0, len);
        System.out.println(data);

        ss.close();
        is.close();
    }
}
